import React, { Component } from 'react'
import '../assets/css/userinfo.scss'
import {fulldateFormat} from '../utils/dateFormat'
import MyDate from './MyDate'
import PropTypes from 'prop-types'
export default class UserInfo extends Component {
  constructor(props){
    super(props)
  }
  static defaultProps={
    title:'暂无标题',
    name:'暂无名称',
    age:0,
    gender:1,
    hobby:['暂无兴趣'],
    birthday:new Date(),
    avatar:'http://old.woniuxy.com/page/img/head_picture/0.jpg'
  }
  static propTypes={
    age:PropTypes.number.isRequired
  }
  giveLike=()=>{
    console.log('点赞数',this.props.likeNum);
    //this.props.likeNum=this.props.likeNum+1
    
    
  }
  render() {
    const {title,name,age,gender,hobby,birthday,avatar,likeNum}=this.props
    return (
      <div className='info-box'>
          <h3>{title}</h3> 
          <div>姓名:{name}</div>
          <div>年龄:{age}</div>
          <div>性别:{gender===1?'男':'女'}</div>
          <div>爱好：{hobby.join("、")}</div> 
          <div>生日:{fulldateFormat(birthday,"/")}</div>
          <div>
             <MyDate date={birthday}></MyDate>
          </div>
          <div>
            点赞数:{likeNum}
            <span style={{marginLeft:'10px',fontSize:'20px',color:'red'}} onClick={this.giveLike}>❤</span>
          </div>
          <div>
            <img src={avatar} alt="" className='avatar'/>
          </div>
      </div>
    )
  }
}

// UserInfo.propTypes={
//   age:PropTypes.number.isRequired
// }



// UserInfo.defaultProps={
//   title:'暂无标题',
//   name:'暂无名称',
//   age:0,
//   gender:1,
//   hobby:['暂无兴趣'],
//   birthday:new Date(),
//   avatar:'http://old.woniuxy.com/page/img/head_picture/0.jpg'
// }
